import { defineStore } from 'pinia';

export const useAuthStore = defineStore('auth', {
  state: () => ({
    sessionId: null as string | null, // 用户会话 ID
  }),
  actions: {
    setSession(sessionId: string) {
      this.sessionId = sessionId; // 设置会话 ID
    },
    clearSession() {
      this.sessionId = null; // 清除会话 ID
    },
  },
  getters: {
    getToken(): string | null {
      return localStorage.getItem('JSESSIONID'); // 返回当前的 sessionId
    },
  }
});